package com.hellojava.util;


import com.hellojava.bean.UUIDEntity;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Created by yuonch on 2016/7/6.
 */
public class EntityUtil {
    public static String[] getIds(Collection<? extends UUIDEntity> entities) {
        if (entities == null)
            return null;
        return entities.stream().map(UUIDEntity::getId).toArray(String[]::new);
    }

    public static List<String> getIdList(Collection<? extends UUIDEntity> entities) {
        if (entities == null)
            return null;
        return entities.stream().map(UUIDEntity::getId).collect(Collectors.toList());
    }

    public static Set<String> getIdSet(Collection<? extends UUIDEntity> entities) {
        if (entities == null)
            return null;
        return entities.stream().map(UUIDEntity::getId).collect(Collectors.toSet());
    }
}
